package com.ruoyi.web.controller.system.statis.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.statis.domain.ServiceStatisMember;
import com.ruoyi.system.statis.service.IServiceStatisMemberService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员统计Controller
 * 
 * @author Administrator
 * @date 2021-03-06
 */
@Controller
@RequestMapping("/statis/member")
public class ServiceStatisMemberController extends BaseController
{
    private String prefix = "statis/member";

    @Autowired
    private IServiceStatisMemberService serviceStatisMemberService;

    @RequiresPermissions("statis:member:view")
    @GetMapping()
    public String member()
    {
        return prefix + "/member";
    }

    /**
     * 查询会员统计列表
     */
    @RequiresPermissions("statis:member:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ServiceStatisMember serviceStatisMember)
    {
        startPage();
        List<ServiceStatisMember> list = serviceStatisMemberService.selectServiceStatisMemberList(serviceStatisMember);
        return getDataTable(list);
    }

    /**
     * 导出会员统计列表
     */
    @RequiresPermissions("statis:member:export")
    @Log(title = "会员统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ServiceStatisMember serviceStatisMember)
    {
        List<ServiceStatisMember> list = serviceStatisMemberService.selectServiceStatisMemberList(serviceStatisMember);
        ExcelUtil<ServiceStatisMember> util = new ExcelUtil<ServiceStatisMember>(ServiceStatisMember.class);
        return util.exportExcel(list, "member");
    }

    /**
     * 新增会员统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会员统计
     */
    @RequiresPermissions("statis:member:add")
    @Log(title = "会员统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ServiceStatisMember serviceStatisMember)
    {
        return toAjax(serviceStatisMemberService.insertServiceStatisMember(serviceStatisMember));
    }

    /**
     * 修改会员统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ServiceStatisMember serviceStatisMember = serviceStatisMemberService.selectServiceStatisMemberById(id);
        mmap.put("serviceStatisMember", serviceStatisMember);
        return prefix + "/edit";
    }

    /**
     * 修改保存会员统计
     */
    @RequiresPermissions("statis:member:edit")
    @Log(title = "会员统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ServiceStatisMember serviceStatisMember)
    {
        return toAjax(serviceStatisMemberService.updateServiceStatisMember(serviceStatisMember));
    }

    /**
     * 删除会员统计
     */
    @RequiresPermissions("statis:member:remove")
    @Log(title = "会员统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(serviceStatisMemberService.deleteServiceStatisMemberByIds(ids));
    }
}
